$(function () {
    $('.div11_span2').on('click',function(){
        $('.div11_box5').show().removeClass('lightSpeedOut').addClass('animated lightSpeedIn');//.fadeIn();
    })
    $('.div11close').on('click',function(){
        $('.div11_box5').removeClass('lightSpeedIn').addClass('animated lightSpeedOut');
        setTimeout(function(){
            $('.div11_box5').hide();
        },400)
    })
    $('.div11_span1').on('click',function(){
        $('.div11_date').show().removeClass('lightSpeedOut').addClass('animated lightSpeedIn');//.fadeIn();
    })
    $('.divdateclose').on('click',function(){
        $('.div11_date').removeClass('lightSpeedIn').addClass('animated lightSpeedOut');
        setTimeout(function(){
            $('.div11_date').hide();
        },400)
    })
    $('.div11_span3').on('click',function(){
        $('.div11_box6').show().removeClass('lightSpeedOut').addClass('animated lightSpeedIn');//.fadeIn();
    })
    $('.div11close' && '.div11_box6 ul li').on('click',function(){
        $('.div11_box6').removeClass('lightSpeedIn').addClass('animated lightSpeedOut');
        setTimeout(function(){
            $('.div11_box6').hide();
        },400)
    })

    $('.form_time').datetimepicker({
        language:  'zh-CN',
        format: 'yyyy',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 4, //这里就设置了默认视图为年视图
        minView: 4, //设置最小视图为年视图
        forceParse: 0,
    });

    function randomData() {
        return Math.round(Math.random() * 1000);
    }
    
    var data = [{
        name: '河南',
        value1: randomData(),
        value2: randomData(),
    }, {
        name: '黑龙江',
        value1: randomData(),
        value2: randomData(),
    }, {
        name: '湖南',
        value1: randomData(),
        value2: randomData(),
    }, {
        name: '安徽',
        value1: randomData(),
        value2: randomData(),
    }, {
        name: '山东',
        value1: randomData(),
        value2: randomData(),
    }, {
        name: '浙江',
        value1: randomData(),
        value2: randomData(),
    }, {
        name: '湖北',
        value1: randomData(),
        value2: randomData(),
    }, {
        name: '山西',
        value1: randomData(),
        value2: randomData(),
    }, {
        name: '陕西',
        value1: randomData(),
        value2: randomData(),
    }, {
        name: '广东',
        value1: randomData(),
        value2: randomData(),
    }];
    
    var resultdata0 = [];
    var resultdata1 = [];
    var resultdata2 = [];
    var sum0 = 0;
    var sum1 = 0;
    var sum2 = 0;
    var titledata = [];
    for (var i = 0; i < data.length; i++) {
        var d0 = {
            name: data[i].name,
            value: data[i].value1 + data[i].value2
        };
        var d1 = {
            name: data[i].name,
            value: data[i].value1
        };
        var d2 = {
            name: data[i].name,
            value: data[i].value2
        };
        titledata.push(data[i].name)
        resultdata0.push(d0);
        resultdata1.push(d1);
        resultdata2.push(d2);
        sum0 += data[i].value1 + data[i].value2;
        sum1 += data[i].value1;
        sum2 += data[i].value2;
    }
    
    function NumDescSort(a,b){
        return a.value-b.value;
    }
    
    resultdata0.sort(NumDescSort);
    resultdata1.sort(NumDescSort);
    resultdata2.sort(NumDescSort);

    var myChart1 = echarts.init(document.getElementById('echart1'));
    option1 = {
        tooltip: {
            trigger: 'item',
        },
        legend: {
            orient: 'vertical',
            left: 'left',
            data: ['全部'],
            selectedMode: 'single',
        },
        grid: {
            right: 40,
            top: 60,
            bottom: 40,
            width: '30%'
        },
        xAxis: [{
            position: 'top',
            type: 'value',
            boundaryGap: false,
            splitLine: {
                show: false
            },
            axisLine: {
                show: false
            },
            axisTick: {
                show: false
            },
        }],
        yAxis: [{
            type: 'category',
            data: titledata,
            axisTick: {
                alignWithLabel: true
            }
        }],
        series: [{
            z: 1,
            name: '发货总件数',
            type: 'map',
            map: 'china',
            left: '10',
            right: '35%',
            top: '0',
            bottom: "35%",
            zoom: 0.75,
            label: {
                normal: {
                    show: true
                },
                emphasis: {
                    show: true
                }
            },
            data: resultdata0
        },
        {
            name: '发货总件数',
            z: 2,
            type: 'bar',
            label: {
                normal: {
                    show: true,
                },
                emphasis: {
                    show: true,
                }
            },
            itemStyle: {
                normal: {
                    color: '#50a1a5',
                },
                emphasis: {
                    color: "#ff7d7b"
                }
            },
            data: resultdata0
        },
        {
            name: '发货总件数',
            z: 2,
            type: 'pie',
            radius: ['17%', '25%'],
            center: ['30%', '82.5%'],
            label: {
                normal: {
                    show: true
                },
                emphasis: {
                    show: true,
                }
            },
            itemStyle: {
                emphasis: {
                    color: "rgb(254,153,78)"
                }
            },
            data: resultdata0
        }]
    };
    myChart1.setOption(option1);
})


